<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="administration.AM" %>
<%@ page import="administration.Admin" %>
<%@ page import="administration.AdminManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ControlPanel || Login</title>
<link rel="stylesheet" href="../styles/adminstyle.css" type="text/css" media="screen" title="default" />
<script language="JavaScript" type="text/javascript">

function check_fields(formname) 
{ 
    var returnval=false; 
    var msg=""; 

    if(formname.name.value=="") 
        msg+="You must fill your username!\n"; 
    if(formname.pwd.value=="") 
        msg+="You must fill your password\n"; 
    if(msg=="") 
    { 
        returnval=true; 
        return returnval; 
    } 
    else 
    { 
        alert(msg); 
        return returnval; 
    } 
} 

function submit_form(formname) 
{ 
    if(check_fields(formname)) 
    { 
        return true; 
    } 
    else 
    { 
        alert("Please, correct your data"); 
        return false; 
    } 
}
 </script>
</head>
<body>
<%
	Admin currAdmin = (Admin) session.getAttribute("currAdmin");
	if(currAdmin==null){
		
%> 
	
	<form name="login" method="post" action="/login">
		<div class="box">
	 		<h1>Admin ControlPanel || Login || Team CWA2</h1>
	        <label>
	        	<span>Username</span>
	         	<input type="text" class="input_text" name="name" id="name" value="username"/>
	        </label>
	        <label>
	         	<span>Password</span>
	            <input type="password" class="input_text" name="pwd" id="pwd" value="************"/>
	     	</label>
	     	<input type="submit" class="button" value="Login" onClick="return submit_form(this.form)" />
	   	</div>
	</form>
	<%} else{ %>
	<form name="course" method="post" action="/addCourse">
		<div class="box">
	 		<h1>Add Course or <a href="/logout" color=#FFFFFF>Log out</a></h1>
	        <label>
	        	<span>Course Name</span>
	         	<input type="text" class="input_text" name="coursename" id="coursename"/>
	        </label>
	        <label>
	         	<span>Prof Name</span>
	            <input type="text" class="input_text" name="profname" id="profname" />
	     	</label>
	     	<label>
	         	<span>Studypoints</span>
	            <input type="text" class="input_text" name="studypoints" id="studypoints" />
	     	</label>
	     	<label>
	         	<span>Description</span>
	            <input type="text" class="input_text" name="desc" id="desc" />
	     	</label>
	     	<input type="submit" class="button" value="add Course" />
	   	</div>
	</form>
	<form name="course" method="post" action="/addCourse">
		<div class="box">
	 		<h1>Add Suggestion</h1>
	        <label>
	        	<span>Did you know ?</span>
	         	<input type="text" class="input_text" name="suggestion" id="suggestion"/>
	        </label>	        
	     	<input type="submit" class="button" value="add Suggestion" />
	   	</div>
	</form>
	<form name="course" method="post" action="/addAdmin">
		<div class="box">
	 		<h1>Add new Admin</h1>
	        <label>
	        	<span>Username</span>
	         	<input type="text" class="input_text" name="username" id="username"/>
	        </label>
	        <label>
	        	<span>Password</span>
	         	<input type="password" class="input_text" name="password" id="password"/>
	        </label>		        
	     	<input type="submit" class="button" value="add Admin" />
	   	</div>
	</form>
	
	<%} %>
</body>
</html>